﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rawdatalist.aspx.cs" Inherits="UI.system.page.rawdata.rawdatalist" %>

<%@ Import Namespace="Model" %>
<%@ Import Namespace="DAL" %>
<%@ Import Namespace="Common" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script src="/js/jquery.min.js"></script>
    <%--<script src="/js/common.js"></script>--%>
    <script src="/system/js/common.js"></script>
    <script src="/js/md5.js"></script>
    <script src="/js/swfupload.js"></script>
    <script src="/system/js/admin.js"></script>
    <script src="/system/layui/layui.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
    <style>
        td img{border-radius:20px; width:40px; height:40px; float:left; margin-left:5px;}
        #getcheckdata{ margin-left:5px;}
    </style>
</head>
<body>    
    <form id="form1" runat="server">
    <div class="layer-toolbar layui-form">
        <div class="layer-toolbar-left">
           <%=MenuDAL.Power("Save") %>
           <a class="layui-btn layui-btn-small  layui-btn-warm" onclick="daoru();">病理导入</a>
           <a class="layui-btn layui-btn-small  layui-btn-warm" onclick="daoru2();">血液导入</a>
           <a class="layui-btn layui-btn-small  layui-btn-normal" id="getcheckdata" data-type="getCheckData">选中入库</a>
        </div>
        <div class="layer-toolbar-right">
           
            <input id="experimentnumber" type="text" name="title" placeholder="实验号" autocomplete="off" class="layui-input" value="" style="width:100px;" onkeyup='CRM.Enter("#search")'>            
            <input id="ucode" type="text" name="title" placeholder="条码号" autocomplete="off" class="layui-input" value="" style="width:100px;" onkeyup='CRM.Enter("#search")'>
            <input id="hospital" type="text" name="title" placeholder="医院" autocomplete="off" class="layui-input" value="" style="width:100px;" onkeyup='CRM.Enter("#search")'>
            <input id="keyword" type="text" name="title" placeholder="用户名、姓名" autocomplete="off" class="layui-input" value="" style="width:100px;" onkeyup='CRM.Enter("#search")'>
            <input id="begindate" type="text" name="title" placeholder="签收开始时间" autocomplete="off" class="layui-input" value="" style="width:100px;"><div class="texts">-</div>
            <input id="enddate" type="text" name="title" placeholder="签收结束时间" autocomplete="off" class="layui-input" value="" style="width:100px;">
            <a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Search()">搜索</a>
            <a id="reflesh" class="layui-btn layui-btn-small" data-type="getCheckData" onclick="Search()">刷新</a>
        </div>
    </div>
     
    <div id="iframe" class="layer-iframe">
    <table class="layui-table" lay-data="{id:'mytable', page:true,limits:[100,200,300,400,500,600,700,800,900,1000], limit:100, loading:true, height:'full-90'}" lay-filter="demo">
      <thead>
        <tr>
          <th lay-data="{checkbox:true,width:80,fixed: true}" name="clicked"></th>
          <%--<th lay-data="{width:100, templet:'<div id=\'{{ d.ID }}\'>{{ d.ID }}</div>'}">测试ID</th>--%>
          <th lay-data="{width:0, toolbar:'#IDs'}"></th>
          <th lay-data="{width:60, toolbar:'#Number'}" style=" text-align:center;">序号</th>
          <%--<th lay-data="{width:50,field:'ID'}">ID</th>--%>
          <th lay-data="{width:160,field:'ExperimentNumber',sort:true}">实验号</th>
          <th lay-data="{width:160,field:'Name'}">姓名</th>
          <th lay-data="{width:160,field:'UCode'}">主条码</th>
          <th lay-data="{width:200,field:'Hospital'}">医院</th>
          <th lay-data="{width:200,field:'Opinions'}">诊断意见</th>
          <th lay-data="{width:160,field:'ReportDoctor'}">报告医生</th>
          <th lay-data="{width:200,field:'EntryName'}">项目名称</th>
          <th lay-data="{width:100,field:'BPCount'}">玻片数量</th>
          <th lay-data="{width:100,field:'LKCount'}">蜡块数量</th>
          <th lay-data="{width:160,field:'BLCode'}">病理号</th>
          <th lay-data="{width:100, templet:'<div>{{d.Sex==0?\'男\':\'女\'}}</div>'}">性别</th>
          <th lay-data="{width:100,field:'Age'}">年龄</th>
          <th lay-data="{width:160,field:'TuWenShu'}">图文数</th>
          <th lay-data="{width:160,field:'DaTuWenShu'}">大体图文数</th>
          <th lay-data="{width:200,field:'Process'}">病理流程</th>
          <th lay-data="{width:160,field:'State'}">状态</th>
          <th lay-data="{width:160,field:'Late'}">迟</th>
          <th lay-data="{width:200,field:'DelayedCause'}">迟发原因</th>
          <th lay-data="{width:160,field:'OutsourcingParty'}">外包方</th>
          <th lay-data="{width:160,field:'Termination'}">终止</th>
          <th lay-data="{width:200,field:'TerminationReason'}">终止原因</th>
          <th lay-data="{width:160,field:'Back'}">退单</th>
          <th lay-data="{width:200,field:'BackReason'}">退单原因</th>
          <th lay-data="{width:160,field:'Submitter'}">提交人</th>
          <th lay-data="{width:160,field:'Auditor'}">审核人</th>
          <th lay-data="{width:160,field:'ReferenceDoctor'}">取材医生</th>
          <th lay-data="{width:200,field:'SpecimenSigningTime'}">标本签收时间</th>          
          <th lay-data="{width:160,toolbar:'#Founder'}">创建人</th>
          <th lay-data="{width:200,field:'Remarks'}">备注</th>          
          <th lay-data="{width:200,field:'CreateDate'}">创建时间</th>
          
          <th lay-data="{width:140, fixed:'right', toolbar:'#handler'}">操作</th>
        </tr>
      </thead>
    </table>
    <script type="text/html" id="handler">
      <%=MenuDAL.Power("") %>
    </script>
     <script type="text/html" id="Founder">
       {{# if(d.Founder=="" || d.Founder==null){}}
            超级管理员
       {{#  }else{ }}
            {{d.Founder}}
       {{# } }} 
    </script>
    <script type="text/html" id="IDs">
      <div class="ids">{{ d.ID }}<div>
    </script>

    <script type="text/html" id="Number">
      <div>{{ d.LAY_TABLE_INDEX+1 }}<div>
    </script>
    </div>
    </form>
    <script>
        layui.use(["form", "table", "laydate"], function () {
            var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
            table = layui.table;
            laydate.render({
                elem: '#begindate'
            });
            laydate.render({
                elem: '#enddate'
            });

            //监听表格复选框选择
            table.on('checkbox(demo)', function (obj) {
                console.log(obj)

            });

            var $1 = layui.$, active = {
                getCheckData: function () { //获取选中数据
                    var checkStatus = table.checkStatus('mytable')
                    , data = checkStatus.data

                    var ids = '';
                    var count = checkStatus.data.length;
                    layui.each(data, function (idx, item) {
                        ids += '' + item.ID + ',';
                    });
                    if (ids != "") {
                        Ajax.Get("/system/page/rawdata/plrukuadd.aspx?count=" + count + "&v=" + Math.random(), function (html) {
                            window.parent.LayerBox.Show("批量入库", html, 580, 430, null, function (form) {
                                var data = form;
                                if (form.pid == "请选择" || form.pid == null || form.pid < 0) {
                                    LayerBox.Error("请输入正确的仓位编码");
                                } else {
                                    data.act = "Save_RuKuByIDS";
                                    data.ids = ids;
                                    var st = new Array();
                                    window.parent.$("#img_panel img").each(function () { //jquery.each()循环读取所有图片  
                                        if ($(this).attr("src") != "/system/img/delete.png") {
                                            st.push($(this).attr("src"));
                                        }
                                    });
                                    data.Imgs = st.join(',');
                                    data.sign = GetSign(data.act);
                                    var index = LayerBox.Loading();
                                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                                        var json = $.parseJSON(r);
                                        if (json.state) {
                                            LayerBox.Success(json.msg, 500, function () {
                                                LayerBox.Close.ByAll();                                               
                                                $(".layui-laypage").remove();
                                                Init_Pager(1);                                               
                                            });
                                        }
                                        else {
                                            LayerBox.Close.ByIndex(index);
                                            LayerBox.Error(json.msg);
                                        }
                                    });
                                }
                            });

                        });

                    } else {
                        LayerBox.Error("请先选择要入库的信息");
                    }

                }
            };

            $('#getcheckdata').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });

            Init_Pager();
        });

        function Init_Pager(pageindex) {
            var data = {};
            data.act = "Find_Rawdata";
            data.pageindex = pageindex;
            data.parentid = $(".layui-table").attr("parentid");
            data.begindate = $("#begindate").val();
            data.enddate = $("#enddate").val();
            data.keyword = $("#keyword").val();
            data.ucode = $("#ucode").val();
            data.hospital = $("#hospital").val();
            data.experimentnumber = $("#experimentnumber").val();
            data.sign = GetSign(data.act);
            table.reload('mytable', {
                url: '/tools/Admin.ashx',
                loading: true,
                where: data
            });
        };

        function Save(o, id) {
            Ajax.Get("/system/page/rawdata/rawdataadd.aspx?id=" + id + "&v=" + Math.random(), function (html) {
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "", html, 460, 560, null, function (form) {
                    var data = form;
                    data.act = "Save_Rawdata";
                    data.id = id;
                    data.sign = GetSign(data.act);
                    var index = LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                if (id == 0) {
                                    $(".layui-laypage").remove();
                                    Init_Pager(1);
                                } else {
                                    var currpage = 1;
                                    if ($(".layui-laypage-curr em").length > 0) {
                                        currpage = $(".layui-laypage-curr em")[1].innerHTML;
                                    }
                                    Init_Pager(currpage);
                                }
                            });
                        }
                        else {
                            //                            LayerBox.Loading();
                            //                            LayerBox.Close.ByAll();
                            LayerBox.Close.ByIndex(index);
                            LayerBox.Error(json.msg);
                        }
                    });
                });
            });
        };


        function Delete(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                Delete_Table(o, id, "Delete_Rawdata");
            });
        };
        function daoru() {
            var dataid = "<%=id %>";            
            var id = "daoru1";
            window.parent.element.tabAdd('demo', {
                title: "导入病理数据",
                content: '<iframe src="/system/page/rawdata/importresult.aspx?id=' + id + '&&dataid='+dataid+'"></iframe>',
                id: id
            });
            
            window.parent.element.tabChange('demo', 'daoru1');
        };
        function daoru2() {
            var dataid = "<%=id %>";
            var id = "daoru2";
            window.parent.element.tabAdd('demo', {
                title: "导入血液数据",
                content: '<iframe src="/system/page/rawdata/importresile2.aspx?id=' + id + '&&dataid=' + dataid + '"></iframe>',
                id: id
            });
            window.parent.element.tabChange('demo', 'daoru2');
        };
        
</script>
</body>
</html>
